home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Special 17 / AMIGAplus Sonderheft 17 (1999)(ICP)(DE)[!].iso / Rexx / ViewFile.pprx < prev    next >
Text File  |  1997-05-06  |  2KB  |  93 lines

  1. /* Personal Paint Amiga Rexx script - Copyright © 1996, 1997 Cloanto Italia srl */
  2.  
  3. /* $VER: ViewFile.pprx 1.0 */
  4.  
  5. /** ENG
  6.  This script shows how to create a simple text viewer. It displays the
  7.  selected text file in a window.
  8. */
  9.  
  10. /** DEU
  11.  Dieses Skript verdeutlicht die Erstellung eines einfachen
  12.  Textanzeigeprogramms. Die ausgewählte Textdatei wird in einem Fenster
  13.  angezeigt.
  14. */
  15.  
  16. /** ITA
  17.  Questo script mostra come creare un semplice visualizzatore di testi.
  18.  Esso mostra il file di testo selezionato all'interno di una finestra.
  19. */
  20.  
  21. IF ARG(1, EXISTS) THEN
  22.     PARSE ARG PPPORT
  23. ELSE
  24.     PPPORT = 'PPAINT'
  25.  
  26. IF ~SHOW('P', PPPORT) THEN DO
  27.     IF EXISTS('PPaint:PPaint') THEN DO
  28.         ADDRESS COMMAND 'Run >NIL: PPaint:PPaint'
  29.         DO 30 WHILE ~SHOW('P',PPPORT)
  30.              ADDRESS COMMAND 'Wait >NIL: 1 SEC'
  31.         END
  32.     END
  33.     ELSE DO
  34.         SAY "Personal Paint could not be loaded."
  35.         EXIT 10
  36.     END
  37. END
  38.  
  39. IF ~SHOW('P', PPPORT) THEN DO
  40.     SAY 'Personal Paint Rexx port could not be opened'
  41.     EXIT 10
  42. END
  43.  
  44. ADDRESS VALUE PPPORT
  45. OPTIONS RESULTS
  46. OPTIONS FAILAT 10000
  47.  
  48. Get 'LANG'
  49. IF RESULT = 1 THEN DO        /* Deutsch */
  50.     txt_req_sel       = 'Textdatei auswählen'
  51.     txt_req_file      = 'Dateiinhalt'
  52.     txt_err_oldclient = 'Für dieses Skript_ist eine neuere Version_von Personal Paint erforderlich'
  53. END
  54. ELSE IF RESULT = 2 THEN DO    /* Italiano */
  55.     txt_req_sel       = 'Selezionare file testo'
  56.     txt_req_file      = 'Contenuto del file'
  57.     txt_err_oldclient = 'Questa procedura richiede_una versione più recente_di Personal Paint'
  58. END
  59. ELSE DO                /* English */
  60.     txt_req_sel       = 'Select a text file'
  61.     txt_req_file      = 'File Contents'
  62.     txt_err_oldclient = 'This script requires a newer_version of Personal Paint'
  63. END
  64.  
  65. Version 'REXX'
  66. IF RESULT < 7 THEN DO
  67.     RequestNotify 'PROMPT "'txt_err_oldclient'"'
  68.     EXIT 10
  69. END
  70.  
  71. LockGUI
  72. RequestFile '"'txt_req_sel'"'
  73. IF RC = 0 THEN DO
  74.     PARSE VALUE RESULT WITH '"' fname '"'
  75.     IF OPEN('textfile', fname, 'R') THEN DO
  76.         filetext = ''
  77.         DO UNTIL EOF('textfile')
  78.             filetext = filetext || READCH('textfile', 10000)
  79.         END
  80.         CALL CLOSE('textfile')
  81.         pos = 1
  82.         DO FOREVER
  83.             pos = INDEX(filetext, '"', pos)
  84.             IF pos = 0 THEN
  85.                 BREAK
  86.             filetext = INSERT('"', filetext, pos)
  87.             pos = pos + 2
  88.         END
  89.         RequestNotify '"'txt_req_file'" "'filetext'" SCROLL WRAPCHECK'
  90.     END
  91. END
  92. UnlockGUI
  93.